#!/usr/bin/env python3
"""这个是程序文档
"""

__all__ = []

# 單行注釋
def mute(*a, **b):
    """函数文档
    """
    pass


def vari():
    print("变量常量")
    a = 1
    b = True
    f = 0.1

    c = 1 if a == 1 else 0
    assert c == 1


def stri():
    print("字符串")
    s = "a\nb"
    s = 'a'+str(1)
    s = 'a%s' % s
    lines = """
        a
        b
    """

    assert s == 'aa1'


def coll():
    print("数组集合")
    arr = []
    set_ = {'a'}
    map_ = {'a': 1}

    arr.append(1)
    set_.add('a')
    map_['b'] = 2

    for a in arr:
        mute(a)

    for k, v in map_.items():
        mute(k, v)

    arr = [i+1 for i in arr if i == 1]
    set_ = {k+'k' for k in set_}
    map_ = {k: v+1 for k, v in map_.items()}

    a=[1,2]
    b=[4,5,6]
    obj=zip(a,b) #这里返回的是zip对象，内含iterable，可以for迭代，每个item是一个元组(1,4),(2,5)，
    c,d=zip(*obj)
    assert c[0]==1
    assert b[0]==4
    # 使用过一次之后obj对象变为空
    assert len(list(obj)) == 0


def proc():
    print("流程控制")
    i = 1
    if i == 1:
        mute(i)
    else:
        mute(0)

    while i < 3:
        mute(i)
        i += 1  # i=i+1

    # no switch


def func():
    print("函数")

    def f(b, c):
        return b+c
    assert f(1, 2) == 3

    arr = [1, 2, 3]
    arr = filter(lambda x: x < 2, arr)


def clas():
    print("类和对象")

    class A (object):
        def __init__(self, a):
            self.a = a

        def f(self, p):
            mute(p)
            mute(self.a)

    a = A('a')
    a.f(0)


def mode():
    print("模块")
    pass


def main():
    # start
    print("Hello World!")
    vari()
    stri()
    coll()
    proc()
    func()
    clas()
    mode()


if __name__ == '__main__':
    main()